#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os

from loguru import logger

from fastpt.core.path_conf import LOG_PATH


class Logger:

    @staticmethod
    def log() -> logger:
        """
        日志记录器

        :return:
        """
        if not os.path.join(LOG_PATH):
            os.makedirs(LOG_PATH)

        log_file = os.path.join(LOG_PATH, 'api_test.log')

        logger.add(
            log_file,
            level='DEBUG',
            rotation='00:00',
            retention='7 days',
            encoding='utf8',
            enqueue=True,
            backtrace=True,
            diagnose=False,
            catch=True
        )

        return logger


log = Logger().log()
